package com.scf.enterprise.mapper;

import com.scf.enterprise.entity.EccontactInfor;
import com.scf.enterprise.entity.EnterpriseIfmtion;
import com.scf.enterprise.entity.LegalPerson;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface EnterpriseMapper {

    List<EnterpriseIfmtion> selectAll(@Param("epinfo")EnterpriseIfmtion epinfo,
                                      @Param("pageIndex") int pageIndex,
                                      @Param("pageSize") int pageSize);

    int selectEpcount(@Param("epinfo")EnterpriseIfmtion epinfo);

    EnterpriseIfmtion selectEpByid(int epid);


    void updateEpById(@Param("epid") int epid,@Param("epstate") int epstate);


    void updateEp(@Param("epinfo")EnterpriseIfmtion epinfo);

    void updateLp(@Param("leper")LegalPerson leper);

    void updateEcc(@Param("ecc")EccontactInfor ecc);

    void insertEp(@Param("epinfo")EnterpriseIfmtion epinfo);

    @Insert("insert into legalperson values(null,#{epinfo.lpid.lpname},#{epinfo.lpid.lpgender},#{epinfo.lpid.lpdtype},#{epinfo.lpid.lpdnumber},#{epinfo.lpid.lpphonenumber},#{epinfo.lpid.lpemile})")
    @Options(useGeneratedKeys=true,keyProperty="epinfo.lpid.lpid",keyColumn="lpid")
    void insertLp(@Param("epinfo")EnterpriseIfmtion epinfo);


    @Insert("insert into eccontactinformation values (null,#{epinfo.eccid.ecname},#{epinfo.eccid.ecpost},#{epinfo.eccid.ecphone},#{epinfo.eccid.ecemile})")
    @Options(useGeneratedKeys = true,keyProperty="epinfo.eccid.eccid",keyColumn="eccid")
    void insertEcc(@Param("epinfo")EnterpriseIfmtion epinfo);


}
